﻿using System.Data;
using System.Text.RegularExpressions;

namespace Altairis.IdentityToolkit {
    internal static class ExtensionMethods {

        public static string[] ToStringArray(this DataTable table) {
            return ToStringArray(table, 0);
        }

        public static string[] ToStringArray(this DataTable table, string columnName) {
            return ToStringArray(table, table.Columns[columnName].Ordinal);
        }

        public static string[] ToStringArray(this DataTable table, int columnIndex) {
            string[] data = new string[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++) data[i] = System.Convert.ToString(table.Rows[i][0]);
            return data;
        }

        public static bool IsRegexMatch(this string s, string pattern) {
            return Regex.IsMatch(s, pattern);
        }
        public static bool IsRegexMatch(this string s, string pattern, RegexOptions options) {
            return Regex.IsMatch(s, pattern, options);
        }

    }

}
